//
//  PrepareAppEngine.m
//  HuLaQuan
//
//  Created by hok on 1/27/16.
//  Copyright © 2016 Jianghao. All rights reserved.
//

#import "PrepareAppEngine.h"

#import "CurrentUser.h"
@implementation PrepareAppEngine

- (void)prepareAppLoading
{
    NSString *randomKey = [self createKeyWithLength:24];
    
    NSString *src = [NSString stringWithFormat: @"<?xml version=\"1.0\" encoding=\"UTF-8\"?><msg service=\"initApp\" sysName=\"attach\" sign=\"RSA\" serialNumber=\"%@\" termId=\"star_open_esa\" termAdd=\"23.23,23.45\" termBrand=\"iPhone\" osVersion=\"iPhone OS 9.1\" appVersion=\"1.0.0\" tokenValue=\"%@\" userId=\"\" channelId=\"88888888\"></msg>",[self getSerialNumber],[CurrentUser sharedInstance].token ? [CurrentUser sharedInstance].token : @""];
    //
    NSLog(@"%@ -- src --- ",src);
    
    NSString *final = [NSString stringWithFormat:@"%@|%@|%@",[self firstString],[self secondStringWithKey:randomKey],[self thirdStringWithBody:src andKey:randomKey]];
    
    NSLog(@"%@",final);
    [YuHTTPClient XMLDataWithUrl:SERVER_HOST_PREAPP parameters:final success:^(BOOL isSuccess, id item){
        
        NSDictionary *result;
        if (isSuccess) {
            
        }else{
            NSLog(@"%@",item);
        }
        [[NSNotificationCenter defaultCenter] postNotificationName:@"PrepareAppFinish" object:result];
    }];
}
@end
